package com.ljp.chat.entity;

import com.ljp.chat.entity.enums.ResultEnum;
import lombok.Data;

import java.io.Serializable;

@Data
@SuppressWarnings("unused")
public class Result<T> implements Serializable {

    private static final long serialVersionUID = 3337439376898084639L;

    private Integer code;

    private String msg;

    private T data;

    public Result<T> Result(Integer code,String msg){
        this.code = code;
        this.msg = msg;
        return this;
    }

    public Result<T> Result(ResultEnum resultEnum){
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
        return this;
    }

    public Result<T> SUCCESS(T data){
        this.code = ResultEnum.SUCCESS.getCode();
        this.msg = ResultEnum.SUCCESS.getMsg();
        this.data = data;
        return this;
    }

    public Result<T> FILED(String msg){
        this.code = ResultEnum.FAILED.getCode();
        this.msg = msg;
        return this;
    }


}
